/**
 * 单用户注册Action
 * 1.需要持久化用户信息, UserService
 * 2.初始化root组 GroupService
 * 3.需要初始化容量, CapacityService 单用户100G
 * 4.需要记录日志, LogService
 */
package com.netdisk.controller;

import static com.netdisk.util.UUIDCreator.getUuId;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.netdisk.entity.Company;
import com.netdisk.vo.CompanyInfo;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Component("companyRegisterAction")
@Scope("prototype")
public class CompanyRegisterAction extends ActionSupport implements ModelDriven{

	private CompanyInfo companyInfo = new CompanyInfo();
	
	
	@Override
	public Object getModel() {
		return companyInfo;
	}
	
	@Override
	public String execute() throws Exception {
			String companyId = getUuId(); //生成企业客户的uuid
			
			HttpServletRequest request = ServletActionContext.getRequest();
			HttpSession	session =  request.getSession();
			//从fromBean里面得到新用户
			Company company = companyInfo.getCompany();
			company.setCompanyId(companyId);
			session.setAttribute("company", company);
			System.out.println("enterprise registerAction");
			return SUCCESS;
		}
}
